//
//  Car_ContrastCalculatorViewController.m
//  CarUser
//
//  Created by ayi on 2019/1/24.
//  Copyright © 2019 王森林. All rights reserved.
//

#import "Car_ContrastCalculatorViewController.h"

#import "CarCalculatorViewModel.h"
@interface Car_ContrastCalculatorViewController ()

@property (nonatomic, strong) CarCalculatorViewModel *viewmodel;
@property (nonatomic, strong) IBOutlet UIScrollView *scroll;

@property (weak, nonatomic) IBOutlet UIButton *allPayBtn;
@property (weak, nonatomic) IBOutlet UIButton *loanperiodBtn;
@property (weak, nonatomic) IBOutlet UIView *headerBtnBgView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *headerBtnBgViewLeft;

@property (weak, nonatomic) IBOutlet UILabel *headerTitle1;
@property (weak, nonatomic) IBOutlet UILabel *headerTitle2;

@property (weak, nonatomic) IBOutlet UILabel *yuegongLab;
@property (weak, nonatomic) IBOutlet UILabel *duohuafeiLab;
@property (weak, nonatomic) IBOutlet UILabel *zonghuafeiLab;

@property (weak, nonatomic) IBOutlet UILabel *carTitleLab;//车型
@property (weak, nonatomic) IBOutlet UILabel *carMoneyLab;//裸车售价

@property (weak, nonatomic) IBOutlet UILabel *loanPeriodContentLab;//贷款期限
@property (weak, nonatomic) IBOutlet UILabel *downPaymentContentLab;//裸车首付
@property (weak, nonatomic) IBOutlet UILabel *needToSpendContentLab;//必要花费
@property (weak, nonatomic) IBOutlet UILabel *insuranceContentLab;//商业保险


@property (weak, nonatomic) IBOutlet UILabel *gouzhishuiContentLab;//购置税
@property (weak, nonatomic) IBOutlet UILabel *chechuanshuiContentLab;//车船使用税
@property (weak, nonatomic) IBOutlet UILabel *qiangxianContentLab;//交强险
@property (weak, nonatomic) IBOutlet UILabel *linpaiContentLab;//临牌费用
@property (weak, nonatomic) IBOutlet UILabel *shangjiaoContentLab;//上缴费用

@property (weak, nonatomic) IBOutlet UIView *insuranceBgView;
@property (weak, nonatomic) IBOutlet UIView *loanPeriodSelectedBgView;//贷款期限选择按钮背景
@property (weak, nonatomic) IBOutlet UIView *downPaymentSelectedBgView;//裸车首付选择按钮背景
@property (weak, nonatomic) IBOutlet UIView *luocheBgView;
@property (weak, nonatomic) IBOutlet UIView *daikuanBgView;
@property (weak, nonatomic) IBOutlet UIView *headerMoreBgView;
@property (weak, nonatomic) IBOutlet UIView *businessBgView;//商业保险背景

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *insuranceTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *loanperiodTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *downpaymentTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *daikuanTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *luocheTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *headerMoreTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *businessTop;


@property (weak, nonatomic) IBOutlet UIButton *daikuanBtn1;
@property (weak, nonatomic) IBOutlet UIButton *daikuanBtn2;
@property (weak, nonatomic) IBOutlet UIButton *luocheBtn1;
@property (weak, nonatomic) IBOutlet UIButton *luocheBtn2;
@property (weak, nonatomic) IBOutlet UIButton *biyaoBtn1;
@property (weak, nonatomic) IBOutlet UIButton *biyaoBtn2;
@property (weak, nonatomic) IBOutlet UIButton *businessBtn2;

@property (nonatomic, strong) UIButton *hasSelectedBtn;

//20190311zzy 增加
@property (weak, nonatomic) IBOutlet UILabel *thirdPartyLiabilityInsuranceLab;//第三方责任险
@property (weak, nonatomic) IBOutlet UIView *thirdPartyLiabilityInsuranceContentView;//
@property (weak, nonatomic) IBOutlet UILabel *vehicleLossInsuranceLab;//车辆损失险
@property (weak, nonatomic) IBOutlet UILabel *fullVehicleTheftandrescueLab;//全车盗抢险
@property (weak, nonatomic) IBOutlet UILabel *glassBrokenInsuranceLab;//玻璃单独破碎险
@property (weak, nonatomic) IBOutlet UIView *glassBrkenInsuranceView;//
@property (weak, nonatomic) IBOutlet UILabel *autoignitionInsuranceLab;//自燃损失
@property (weak, nonatomic) IBOutlet UILabel *nofranchiseInsuranceLab;//不计免赔特约险
@property (weak, nonatomic) IBOutlet UILabel *whithoutResponsibilityLab;//无过责任险
@property (weak, nonatomic) IBOutlet UILabel *peopleResponsibilityLab;//车上人员责任险
@property (weak, nonatomic) IBOutlet UILabel *bodyScratchesLab;//车身划痕险
@property (weak, nonatomic) IBOutlet UIView *bodyScratchesContentView;

@end




@implementation Car_ContrastCalculatorViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"购车计算器";
    
    self.allPayBtn.titleLabel.font = FONT_SIZE(16);
    [self.allPayBtn setTitleColor:[CommonMethod colorFromHexString:@"#c3c3c3"] forState:UIControlStateNormal];
    [self.allPayBtn setTitleColor:UIColor.whiteColor forState:UIControlStateSelected];
    self.allPayBtn.selected = YES;
    
    self.loanperiodBtn.titleLabel.font = FONT_SIZE(16);
    [self.loanperiodBtn setTitleColor:[CommonMethod colorFromHexString:@"#c3c3c3"] forState:UIControlStateNormal];
    [self.loanperiodBtn setTitleColor:UIColor.whiteColor forState:UIControlStateSelected];
    self.loanperiodBtn.selected = NO;
    
    self.headerBtnBgViewLeft.constant = 0;
    self.headerMoreTop.constant = -60;
    self.daikuanTop.constant = -88;
    self.luocheTop.constant = -88;
    self.insuranceTop.constant = - 44 * 5;
    self.insuranceBgView.alpha = 0;
    
    self.businessTop.constant =  44;
    self.businessBgView.alpha = 0;
    self.businessBtn2.selected = NO;
    
    self.businessBgView.alpha = 0;
    self.businessTop.constant = -528;
    
    self.daikuanBtn1.selected = YES;
    self.daikuanBtn2.selected = YES;
    self.luocheBtn1.selected = YES;
    self.luocheBtn2.selected = YES;
    
    [self.daikuanBtn2 setImage:IMG(@"xiala_default") forState:UIControlStateNormal];
    [self.daikuanBtn2 setImage:IMG(@"xiala_height") forState:UIControlStateSelected];
    [self.luocheBtn2 setImage:IMG(@"xiala_default") forState:UIControlStateNormal];
    [self.luocheBtn2 setImage:IMG(@"xiala_height") forState:UIControlStateSelected];
    [self.biyaoBtn2 setImage:IMG(@"xiala_default") forState:UIControlStateNormal];
    [self.biyaoBtn2 setImage:IMG(@"xiala_height") forState:UIControlStateSelected];
    [self.businessBtn2 setImage:IMG(@"xiala_default") forState:UIControlStateNormal];
    [self.businessBtn2 setImage:IMG(@"xiala_height") forState:UIControlStateSelected];
    
    _viewmodel = [[CarCalculatorViewModel alloc]init];
    _viewmodel.childvc = self;
    _viewmodel.carmodel = self.carmodel;
    
    self.allPayBtn.hidden = YES;
    self.loanperiodBtn.hidden = YES;
    [self addRac];
    [self.viewmodel.raccommand execute:@(1)];
}


- (void)addRac{
    self.carTitleLab.text = self.carmodel.CXMC00;
    self.carMoneyLab.text = [CarCalculatorViewModel stringChangeMoneyWithDouble:(long)([self.carmodel.ZDJG00 floatValue] * 10000)];
    
    RAC(self, headerTitle1.text) = RACObserve(self.viewmodel, headertext1);
    RAC(self.headerTitle2, attributedText) = RACObserve(self.viewmodel, headertext2);
    RAC(self.yuegongLab, attributedText) = RACObserve(self.viewmodel, yuegongtext);
    RAC(self.duohuafeiLab, attributedText) = RACObserve(self.viewmodel, duohuafeitext);
    RAC(self.zonghuafeiLab, attributedText) = RACObserve(self.viewmodel, zonghuafeitext);
    RAC(self, loanPeriodContentLab.text) = RACObserve(self.viewmodel, loanPeriodContenttext);
    RAC(self, downPaymentContentLab.text) = RACObserve(self.viewmodel, downPaymentContenttext);
    RAC(self, needToSpendContentLab.text) = RACObserve(self.viewmodel, needToSpendContenttext);
//    RAC(self, insuranceContentLab.text) = RACObserve(self.viewmodel, insuranceContenttext);
    
    RAC(self, gouzhishuiContentLab.text) = RACObserve(self.viewmodel, gouzhishuiContenttext);
    RAC(self, chechuanshuiContentLab.text) = RACObserve(self.viewmodel, chechuanshuiContenttext);
    RAC(self, qiangxianContentLab.text) = RACObserve(self.viewmodel, qiangxianContenttext);
    RAC(self, linpaiContentLab.text) = RACObserve(self.viewmodel, linpaiContenttext);
    RAC(self, shangjiaoContentLab.text) = RACObserve(self.viewmodel, shangjiaoContenttext);
    
    
    RAC(self, thirdPartyLiabilityInsuranceLab.text) = RACObserve(self.viewmodel, vaule_more_1);
    RAC(self, vehicleLossInsuranceLab.text) = RACObserve(self.viewmodel, vaule_more_2);
    RAC(self, fullVehicleTheftandrescueLab.text) = RACObserve(self.viewmodel, vaule_more_3);
    RAC(self, glassBrokenInsuranceLab.text) = RACObserve(self.viewmodel, vaule_more_4);
    RAC(self, autoignitionInsuranceLab.text) = RACObserve(self.viewmodel, vaule_more_5);
    RAC(self, nofranchiseInsuranceLab.text) = RACObserve(self.viewmodel, vaule_more_6);
    RAC(self, whithoutResponsibilityLab.text) = RACObserve(self.viewmodel, vaule_more_7);
    RAC(self, peopleResponsibilityLab.text) = RACObserve(self.viewmodel, vaule_more_8);
    RAC(self, bodyScratchesLab.text) = RACObserve(self.viewmodel, vaule_more_9);
    RAC(self, insuranceContentLab.text) = RACObserve(self.viewmodel, vaule_more_all);
    
    
    
    @weakify(self);
    [[self.viewmodel.raccommand.executionSignals switchToLatest] subscribeNext:^(id  _Nullable x) {
        @strongify(self);
        self.allPayBtn.hidden = NO;
        self.loanperiodBtn.hidden = NO;
        
        [self.loanPeriodSelectedBgView removeAllSubviews];
        CGFloat width1 = BOUNDWIDTH / (self.viewmodel.PZLXDM_2.count + 2);
        [self.viewmodel.PZLXDM_2 enumerateObjectsUsingBlock:^(PZLXDMModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            UIButton *onebtn = [UIButton buttonWithType:UIButtonTypeCustom];
            onebtn.tag = idx + 100;
            onebtn.titleLabel.font = [UIFont systemFontOfSize:13];
            [onebtn setTitleColor:Common_TextColor forState:UIControlStateNormal];
            [onebtn setTitle:obj.PZMC01 forState:UIControlStateNormal];
            [onebtn setImage:IMG(@"dian") forState:UIControlStateNormal];
            [onebtn setImage:IMG(@"dianheight") forState:UIControlStateSelected];
            [onebtn addTarget:self action:@selector(loanPeriodChildBtnAction:) forControlEvents:UIControlEventTouchUpInside];
            onebtn.selected = obj.hasChoose;
            onebtn.frame = CGRectMake( idx * (10+width1), 0, width1, 44);
            [self.loanPeriodSelectedBgView addSubview:onebtn];
        }];
        
        
        [self.downPaymentSelectedBgView removeAllSubviews];
        CGFloat width2 = BOUNDWIDTH / (self.viewmodel.PZLXDM_1.count + 2);
        [self.viewmodel.PZLXDM_1 enumerateObjectsUsingBlock:^(PZLXDMModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            UIButton *onebtn = [UIButton buttonWithType:UIButtonTypeCustom];
            onebtn.tag = idx + 100;
            onebtn.titleLabel.font = [UIFont systemFontOfSize:13];
            [onebtn setTitleColor:Common_TextColor forState:UIControlStateNormal];
            [onebtn setTitle:obj.PZMC01 forState:UIControlStateNormal];
            [onebtn setImage:IMG(@"dian") forState:UIControlStateNormal];
            [onebtn setImage:IMG(@"dianheight") forState:UIControlStateSelected];
            [onebtn addTarget:self action:@selector(downPaymentChildBtnAction:) forControlEvents:UIControlEventTouchUpInside];
            onebtn.selected = obj.hasChoose;
            onebtn.frame = CGRectMake( idx * (width2+10), 0, width2, 44);
            [self.downPaymentSelectedBgView addSubview:onebtn];
        }];
        
        [self.thirdPartyLiabilityInsuranceContentView removeAllSubviews];
        CGFloat width3 = BOUNDWIDTH / (self.viewmodel.PZLXDM_7.count + 2);
        [self.viewmodel.PZLXDM_7 enumerateObjectsUsingBlock:^(PZLXDMModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            UIButton *onebtn = [UIButton buttonWithType:UIButtonTypeCustom];
            onebtn.tag = idx + 100;
            onebtn.titleLabel.font = [UIFont systemFontOfSize:13];
            [onebtn setTitleColor:Common_TextColor forState:UIControlStateNormal];
            [onebtn setTitle:obj.PZMC01 forState:UIControlStateNormal];
            [onebtn setImage:IMG(@"dian") forState:UIControlStateNormal];
            [onebtn setImage:IMG(@"dianheight") forState:UIControlStateSelected];
            [onebtn addTarget:self action:@selector(thirdPartyLiabilityInsuranceContentViewAction:) forControlEvents:UIControlEventTouchUpInside];
            onebtn.selected = obj.hasChoose;
            onebtn.frame = CGRectMake( idx * (width3+10), 0, width3, 44);
            [self.thirdPartyLiabilityInsuranceContentView addSubview:onebtn];
        }];
        
        [self.glassBrkenInsuranceView removeAllSubviews];
        CGFloat width4 = BOUNDWIDTH / (self.viewmodel.custom_glass_PZLXDM.count + 2);
        [self.viewmodel.custom_glass_PZLXDM enumerateObjectsUsingBlock:^(PZLXDMModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            UIButton *onebtn = [UIButton buttonWithType:UIButtonTypeCustom];
            onebtn.tag = idx + 100;
            onebtn.titleLabel.font = [UIFont systemFontOfSize:13];
            [onebtn setTitleColor:Common_TextColor forState:UIControlStateNormal];
            [onebtn setTitle:obj.PZMC01 forState:UIControlStateNormal];
            [onebtn setImage:IMG(@"dian") forState:UIControlStateNormal];
            [onebtn setImage:IMG(@"dianheight") forState:UIControlStateSelected];
            [onebtn addTarget:self action:@selector(glassBrkenInsuranceViewAction:) forControlEvents:UIControlEventTouchUpInside];
            onebtn.selected = obj.hasChoose;
            onebtn.frame = CGRectMake( idx * (width4+10), 0, width4, 44);
            [self.glassBrkenInsuranceView addSubview:onebtn];
        }];
        
        [self.bodyScratchesContentView removeAllSubviews];
        CGFloat width5 = BOUNDWIDTH / (self.viewmodel.PZLXDM_10.count + 2);
        [self.viewmodel.PZLXDM_10 enumerateObjectsUsingBlock:^(PZLXDMModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            UIButton *onebtn = [UIButton buttonWithType:UIButtonTypeCustom];
            onebtn.tag = idx + 100;
            onebtn.titleLabel.font = [UIFont systemFontOfSize:13];
            [onebtn setTitleColor:Common_TextColor forState:UIControlStateNormal];
            [onebtn setTitle:obj.PZMC01 forState:UIControlStateNormal];
            [onebtn setImage:IMG(@"dian") forState:UIControlStateNormal];
            [onebtn setImage:IMG(@"dianheight") forState:UIControlStateSelected];
            [onebtn addTarget:self action:@selector(bodyScratchesContentViewAction:) forControlEvents:UIControlEventTouchUpInside];
            onebtn.selected = obj.hasChoose;
            onebtn.frame = CGRectMake( idx * (width5+10), 0, width5, 44);
            [self.bodyScratchesContentView addSubview:onebtn];
        }];
        
    }];
    
}





- (IBAction)allpayBtnAction:(UIButton *)sender {
    
    
    self.allPayBtn.selected = YES;
    self.loanperiodBtn.selected = NO;
    [self freshUI:sender];
}

- (IBAction)loanperiodBtnAction:(UIButton *)sender {
    self.allPayBtn.selected = NO;
    self.loanperiodBtn.selected = YES;
    [self freshUI:sender];
}

- (void)freshUI:(UIButton *)btn{
//    if (btn == self.hasSelectedBtn) {
//        return;
//    }
//    self.hasSelectedBtn = btn;
    if (btn == self.allPayBtn) {
        self.viewmodel.currentType = 1;
        [UIView animateWithDuration:0.35 animations:^{
            
            
            self.headerMoreBgView.alpha = 0;
            self.daikuanBgView.alpha = 0;
            self.luocheBgView.alpha = 0;
            self.loanPeriodSelectedBgView.alpha = 0;
            self.downPaymentSelectedBgView.alpha = 0;
            
            self.headerBtnBgViewLeft.constant = 0;
            self.headerMoreTop.constant = -60;
            
            self.daikuanTop.constant = -44 + (self.daikuanBtn1.selected ? -44 : 0);
            self.luocheTop.constant = -44 + (self.luocheBtn1.selected ? -44 : 0);
            
            [self.view layoutIfNeeded];
        } completion:^(BOOL finished) {
            
//            self.daikuanBtn1.selected = YES;
//            self.daikuanBtn2.selected = YES;
//            self.luocheBtn1.selected = YES;
//            self.luocheBtn2.selected = YES;
            
        }];

    }else{
        self.viewmodel.currentType = 2;
        [UIView animateWithDuration:0.35 animations:^{
            
            
            self.headerMoreBgView.alpha = 1;
            self.daikuanBgView.alpha = 1;
            self.luocheBgView.alpha = 1;
            self.loanPeriodSelectedBgView.alpha = 1;
            self.downPaymentSelectedBgView.alpha = 1;
            
            self.headerBtnBgViewLeft.constant = BOUNDWIDTH/2;
            self.headerMoreTop.constant = 0;
            self.daikuanTop.constant = 0;
            self.luocheTop.constant = 0;
            self.loanperiodTop.constant = 0;
            self.downpaymentTop.constant = 0;
            
            [self.view layoutIfNeeded];
        } completion:^(BOOL finished) {
            
            
            self.daikuanBtn1.selected = YES;
            self.daikuanBtn2.selected = YES;
            self.luocheBtn1.selected = YES;
            self.luocheBtn2.selected = YES;
            
        }];
        
    }
}

- (IBAction)daikuanBtnBgAction:(UIButton *)sender {
    sender.selected = !sender.selected;
    self.daikuanBtn2.selected = sender.selected;
    
    if (!sender.selected) {
        
        [UIView animateWithDuration:0.35 animations:^{
            
            self.loanPeriodSelectedBgView.alpha = 0;
            self.loanperiodTop.constant = -44;
            
            [self.view layoutIfNeeded];
        } completion:^(BOOL finished) {
            
        }];
        
    }else{
        
        [UIView animateWithDuration:0.35 animations:^{
            
            self.loanPeriodSelectedBgView.alpha = 1;
            self.loanperiodTop.constant = 0;
            
            [self.view layoutIfNeeded];
        } completion:^(BOOL finished) {
            
        }];
    }
}
- (IBAction)luocheBtnAction:(UIButton *)sender {
    
    sender.selected = !sender.selected;
    self.luocheBtn2.selected = sender.selected;
    
    if (!sender.selected) {
        
        [UIView animateWithDuration:0.35 animations:^{
            
            self.downPaymentSelectedBgView.alpha = 0;
            self.downpaymentTop.constant = -44;
            
            [self.view layoutIfNeeded];
        } completion:^(BOOL finished) {
            
        }];
        
    }else{
        
        [UIView animateWithDuration:0.35 animations:^{
            
            self.downPaymentSelectedBgView.alpha = 1;
            self.downpaymentTop.constant = 0;
            
            [self.view layoutIfNeeded];
        } completion:^(BOOL finished) {
            
        }];
    }
    
}

- (IBAction)huafeiBtnBgAction:(UIButton *)sender {
    
    sender.selected = !sender.selected;
    self.biyaoBtn2.selected = sender.selected;
    
    if (!sender.selected) {
        
        [UIView animateWithDuration:0.55 animations:^{
            
            self.insuranceBgView.alpha = 0;
            self.insuranceTop.constant = - 44 * 5;
            
            [self.view layoutIfNeeded];
        } completion:^(BOOL finished) {
            
        }];
        
    }else{
        
        [UIView animateWithDuration:0.35 animations:^{
            
            self.insuranceBgView.alpha = 1;
            self.insuranceTop.constant = 0;
            
            [self.view layoutIfNeeded];
        } completion:^(BOOL finished) {
            
        }];
    }
    
}

- (IBAction)businessBtnAction:(UIButton *)sender {
    
    sender.selected = !sender.selected;
    self.businessBtn2.selected = sender.selected;
    
    if (!sender.selected) {
        
        [UIView animateWithDuration:0.35 animations:^{
            
            self.businessBgView.alpha = 0;
            self.businessTop.constant = -528;
            [self.view layoutIfNeeded];
        } completion:^(BOOL finished) {
            
        }];
        
    }else{
        
        [UIView animateWithDuration:0.35 animations:^{
            
            self.businessBgView.alpha = 1;
            self.businessTop.constant = 0;
            [self.view layoutIfNeeded];
        } completion:^(BOOL finished) {
            
        }];
    }
    
}


- (void)loanPeriodChildBtnAction:(UIButton *)btn{
    @weakify(self);
    [self.viewmodel.PZLXDM_2 enumerateObjectsUsingBlock:^(PZLXDMModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        @strongify(self);
        obj.hasChoose = NO;
        if (idx == btn.tag - 100) {
            obj.hasChoose = YES;
            [self.viewmodel loanPeriodBtnTouch:obj];
        }
        UIButton *onebtn = [self.loanPeriodSelectedBgView viewWithTag:idx + 100];
        onebtn.selected = obj.hasChoose;
    }];
}

- (void)downPaymentChildBtnAction:(UIButton *)btn{
    @weakify(self);
    [self.viewmodel.PZLXDM_1 enumerateObjectsUsingBlock:^(PZLXDMModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        @strongify(self);
        obj.hasChoose = NO;
        if (idx == btn.tag - 100) {
            obj.hasChoose = YES;
            [self.viewmodel downPaymentBtnTouch:obj];
        }
        UIButton *onebtn = [self.downPaymentSelectedBgView viewWithTag:idx + 100];
        onebtn.selected = obj.hasChoose;
    }];
}


- (void)thirdPartyLiabilityInsuranceContentViewAction:(UIButton *)btn{
    @weakify(self);
    [self.viewmodel.PZLXDM_7 enumerateObjectsUsingBlock:^(PZLXDMModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        @strongify(self);
        obj.hasChoose = NO;
        if (idx == btn.tag - 100) {
            obj.hasChoose = YES;
            [self.viewmodel moreDataInitMore];
        }
        UIButton *onebtn = [self.thirdPartyLiabilityInsuranceContentView viewWithTag:idx + 100];
        onebtn.selected = obj.hasChoose;
    }];
}

- (void)glassBrkenInsuranceViewAction:(UIButton *)btn{
    @weakify(self);
    [self.viewmodel.custom_glass_PZLXDM enumerateObjectsUsingBlock:^(PZLXDMModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        @strongify(self);
        obj.hasChoose = NO;
        if (idx == btn.tag - 100) {
            obj.hasChoose = YES;
            [self.viewmodel moreDataInitMore];
        }
        UIButton *onebtn = [self.glassBrkenInsuranceView viewWithTag:idx + 100];
        onebtn.selected = obj.hasChoose;
    }];
}

- (void)bodyScratchesContentViewAction:(UIButton *)btn{
    @weakify(self);
    [self.viewmodel.PZLXDM_10 enumerateObjectsUsingBlock:^(PZLXDMModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        @strongify(self);
        obj.hasChoose = NO;
        if (idx == btn.tag - 100) {
            obj.hasChoose = YES;
            [self.viewmodel moreDataInitMore];
        }
        UIButton *onebtn = [self.bodyScratchesContentView viewWithTag:idx + 100];
        onebtn.selected = obj.hasChoose;
    }];
}




@end
